import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Reptile } from './entities/reptile.entity';
import { Repository } from 'typeorm';
import { PageDto } from '../reptile/entities/page.dto';
import { CommonService } from '../../common/common.service';

@Injectable()
export class ReptileService {
  private page = 1;

  constructor(
    @InjectRepository(Reptile) private reptileModel: Repository<Reptile>,
    private commonService: CommonService,
  ) {
    // let page = 1
    //  this.getInformation()
  }

  async getReptile(page: PageDto) {
    let { pageNum, pageSize } = page;
    const skip = (pageNum - 1) * pageSize;
    let result = await this.reptileModel.findAndCount({
      skip,
      take: pageSize,
    });

    return result;
  }
}
